package com.twu.biblioteca.command;

import com.twu.biblioteca.Reader;
import com.twu.biblioteca.ServiceDesk;

/**
 * Created with IntelliJ IDEA.
 * User: twer
 * Date: 5/22/13
 * Time: 11:09 PM
 * To change this template use File | Settings | File Templates.
 */
public class LoginCommand implements Command {
    @Override
    public String service(ServiceDesk serviceDesk, Reader reader) {
        if (serviceDesk.isLogin(reader)){
            return "You have already logged in!";
        }
        serviceDesk.authenticate(reader);
        if (serviceDesk.isLogin(reader)){
            return "Congratulations! You login successfully!";
        }
        return "sorry, You didn't pass our Authentication!";
    }

    @Override
    public String title() {
        return "login";
    }
}